package com.wzy.mall.web.servlet.admin;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/admin/admin/*")
public class AdminServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取真正请求的servlet
        String requestURI = request.getRequestURI();
        String action = requestURI.replace("/api/admin/admin/", "");
        //System.out.println(action);
        if("login".equals(action)) {
            Admin.login(request, response);

        } else if("allAdmins".equals(action)) {
            Admin.allAdmins(request, response);

        } else if("addAdminss".equals(action)) {
            Admin.addAdminss(request, response);

        } else if("deleteAdmins".equals(action)) {
            Admin.deleteAdmins(request, response);

        } else if("getSearchAdmins".equals(action)) {
            Admin.ConditionalQuery(request, response);

        } else if("getAdminsInfo".equals(action)) {
            Admin.getAdminsInfo(request,response);

        } else if("updateAdminss".equals(action)) {
            Admin.updateAdminss(request, response);

        } else if("changePwd".equals(action)) {
            Admin.changePwd(request, response);

        } else if("logoutAdmin".equals(action)) {
            Admin.logoutAdmin(request, response);

        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
